<template>
  <div class="list-container">
    <el-table
      ref="tableSort"
      v-loading="listLoading"
      :data="list"
      style="width: 100%"
      :element-loading-text="elementLoadingText"
      :height="height"
    >
      <el-table-column show-overflow-tooltip prop="logName" label="日志名称">
        <template #default="{ row }">
          <el-link :href="getDownloadLink(row.logName)">
            {{ row.logName }}
          </el-link>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
  import { getLogs } from '@/api/log'
  import _net from '../../config/net.config'

  export default {
    name: 'Log',
    data() {
      return {
        list: [],
        listLoading: true,
        layout: 'total, sizes, prev, pager, next, jumper',
        background: true,
        elementLoadingText: '正在加载...',
      }
    },
    computed: {
      height() {
        return this.$baseTableHeight()
      },
    },
    created() {
      this.fetchData()
    },
    mounted() {},
    methods: {
      getDownloadLink(name) {
        let base = _net.baseURL

        return base + '/file/downloadLog?logName=' + name
      },
      async fetchData() {
        this.listLoading = true
        const { data } = await getLogs()
        const { body } = data
        console.log(body)
        this.list = body
        this.$baseNotify('数据获取完毕！', '成功', 'success', 'top-right')
        // data.forEach((item, index) => {})
        setTimeout(() => {
          this.listLoading = false
        }, 500)
      },
    },
  }
</script>
<style lang="scss" scoped></style>
